package day_2022_12_to_3.day;

/**
 * @author haomin
 * @date 2022/12/15 14:09
 **/
public class Day12_15_Num1945 {
    class Solution {
        public int getLucky(String s, int k) {
            StringBuffer sb = new StringBuffer();
            for(char c : s.toCharArray()) sb.append(c-'a' + 1);
            int sum = 0;
            while(k-- > 0) {
                sum = 0;
                for(char c : sb.toString().toCharArray()) sum += (c - '0');
                sb = new StringBuffer();
                sb.append(sum);
            }
            return sum;
        }
    }
}